package com.service.impl;

import com.bean.entity.Specifications;
import com.dao.SpecificationsMapper;
import com.service.SpecificationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpecificationsServiceImpl implements SpecificationsService {

    //自动注入
    @Autowired
    SpecificationsMapper specificationsMapper;

    @Override
    public List<Specifications> queryAll(Specifications specifications) {
        return specificationsMapper.select(specifications);
    }

    @Override
    public int remove(Specifications specifications) throws Exception {
        //修改信息
        int i = specificationsMapper.delete(specifications);
        if(i == 1){
            return 1;
        }else{
            throw new Exception("删除失败！");
        }
    }

    @Override
    public int modify(Specifications specifications) throws Exception {
        //修改信息
        int i = specificationsMapper.update(specifications);
        if(i == 1){
            return 1;
        }else{
            throw new Exception("修改失败！");
        }
    }

    @Override
    public int save(Specifications specifications) throws Exception {
        //修改信息
        int i = specificationsMapper.insert(specifications);
        if(i == 1){
            return 1;
        }else{
            throw new Exception("新增失败！");
        }
    }
}
